package com.itheima.test4;

import java.util.Objects;

public class Test4Objects {
    public static void main(String[] args) {
        Student student1 = new Student("张三", 23);
        Student student2 = new Student("李四", 24);
        Student student3 = null;
        String s1 = Objects.toString(student1);//返回参数中对象字符串的表现形式        //Student{name='张三', age=23}
        System.out.println(s1);
        String s2 = Objects.toString(student3,"我是null啊");//返回参数中对象字符串的表现形式,
                                                                       // 如果对象是null,就返回第2个参数     //我是null啊
        System.out.println(s2);
        boolean aNull = Objects.isNull(student2);//判断对象是不是null          //false
        System.out.println(aNull);
        boolean b = Objects.nonNull(student2);//对象不是null?              //true
        System.out.println(b);

    }
}
